import { getLocal } from '../../utils/local'

const state = {
  token: getLocal('heimamm-mobile-token'), // token
  userInfo: getLocal('heimamm-mobile-user')
    ? JSON.parse(getLocal('heimamm-mobile-user') as string)
    : null // 用户信息
}

interface StateObj {
  token: string
  userInfo: null
}

const mutations = {
  setUserInfo (state: StateObj, user: any) {
    state.userInfo = user
  },
  setToken (state: StateObj, token: string) {
    state.token = token
  }
}

export default {
  namespaced: true,
  state,
  mutations
}
